<template>
  <div id="app">
    <keep-alive>
      <router-view :key="key" v-if="this.$route.meta.keepAlive"></router-view>
      <!--这里是会被缓存的组件-->
    </keep-alive>
    <router-view v-if="!this.$route.meta.keepAlive"></router-view>
    <!--        <router-view/>-->
  </div>
</template>

<script>
import { mapState, mapActions ,mapMutations } from "vuex";
import { getConfigList } from "./api/config";
import { baseLogin } from "./api/common";
import { isWechat } from "./util/wechat";

export default {
  name: "App",
  data() {
    return {};
  },
  computed: {
    ...mapState({
      isOnline: (state) => state.member.isOnline,
      openid: (state) => state.member.openid,

    }),
  },
  created: function () {
            // this.openIdUpdate({openid:'123213212132'});


    getConfigList().then((res) => {
      document.title = res.result.config_list.site_name;
    });

    if (this.$route.query.wechat_id) {
      localStorage.setItem("wechat_id", this.$route.query.wechat_id);
    }
    // &&this.isOnline
    // if (isWechat()) {
    //   if (this.$route.query.openid) {
    //   } else {
    //   }
    // }
    // if(isWechat()&&!this.$route.query.openid){

    // }
    if (isWechat()) {
      if (this.$route.query.openid || this.openid) {
        if(this.$route.query.openid){
          this.openIdUpdate({openid:this.$route.query.openid});
        }
      } else {
        baseLogin(location.href.split("#")[0]).then((res) => {
          console.log(res);
          location.href = res.result;
        });
      }
    }
  },
  methods: {
    ...mapMutations({
      openIdUpdate: "openIdUpdate",
    }),
  },
};
</script>
<style lang="scss">
  strong{font-weight:bold !important}
</style>
